package com.sf.sgs.sessionevaluate.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sf.sgs.sessionevaluate.controller.dto.req.QuestionAnswerCompositeReq;
import com.sf.sgs.sessionevaluate.controller.response.RestResponse;
import com.sf.sgs.sessionevaluate.service.IQuestionAnswerService;

@Component
@RequestMapping("questionAnswers")
public class QuestionAnswerController extends BaseController {

	@Autowired
	private IQuestionAnswerService questionAnswerService;

	// 问卷答案保存接口
	@RequestMapping(method = RequestMethod.POST)
	@ResponseBody
	public RestResponse<?> save(@RequestBody QuestionAnswerCompositeReq questionAnswerCompositeReq) {
		return handle(new Action<Boolean>() {

			@Override
			public void onHandle(RestResponse<Boolean> restResponse) {
				questionAnswerService.saveAnswerForOption(questionAnswerCompositeReq.getQuestionAnswerReqList());
				restResponse.setResult(true);
			}
		});

	}
}
